package com.atguigu.netty.http;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.http.HttpServerCodec;

/**
 * @author: 叶子
 * @date: 2022/02/09 12:33
 **/
public class TestServerInitializer extends ChannelInitializer<SocketChannel> {
    @Override
    protected void initChannel(SocketChannel ch) throws Exception {
//        向管道加入处理器
//        得到管道
        ChannelPipeline pipeline = ch.pipeline();
//        加入一个Netty提供的httpServerCodec   codec => coder - decoder
//        HttpServerCodec 说明
//        1.HttpServerCodec是Netty提供的处理http的编码解码器
        pipeline.addLast("MyHttpServerCodec",new HttpServerCodec());
//        2.增加一个自定义的handler
        pipeline.addLast("MyTestHttpServerHandler",new TestHttpServerHandler());
    }
}